//
//  CAnAlgActIntnstyHisData.m
//  CareRingApp
//
//  Created  on 2025/1/16.
//  0xD1
    

#import "CAnAlgActIntnstyHisData.h"

@implementation CAnAlgActIntnstyHisData


-(instancetype)initWith:(NSData *)data
{
    if (self = [super init]) {
        if (data.length != 20) {
            return self;
        }
        uint8_t * dataBytes = (uint8_t *)[data bytes];
        uint32_t lastTs = *((uint32_t *)(dataBytes + 2));
        self.timeStamp = lastTs;
        
        uint32_t uuid = (dataBytes[8]<< 16) +(dataBytes[7]<< 8) +dataBytes[6];
        if (uuid != 0XFFFFFF) {
            self.dataUuid = @(uuid);
        }
        
        uint16_t step = *((uint16_t *)(dataBytes + 9));
        self.step = @(step);
        
        if (dataBytes[11] != 0XFF) {
            self.skinTemp = @((dataBytes[11] + 200) * 1.0f/10.0f);
        }
        self.activityIntensity = dataBytes[12] & 0xFF;
        
        uint16_t accStandardDeviation = *((uint16_t *)(dataBytes + 13));
        self.accStandardDeviation = @(accStandardDeviation);
        
    }
    return self;
}

-(NSNumber *)dataTimeStamp
{
    return @(self.timeStamp);
}

@end
